package com.wframe.project.former.dataservices.floor;

import java.util.List;

import org.hibernate.HibernateException;

import com.frame.database.JBaseService;
import com.frame.database.JServiceFactory;
import com.frame.database.JdataBean;
import com.frame.database.PageResult;
import com.frame.database.util.ConditionMap;

public class FloorService extends JBaseService<FloorDao>{

	public static FloorService getIntance(){
        return JServiceFactory.createJServiceProxy(FloorService.class);
    }
	
	public List<JdataBean> queryFloors(JdataBean parms) throws Exception{
		ConditionMap condition=new ConditionMap();
		condition.addOrder("orderno", true);
		condition.addOrder("id", true);
		condition.put("status<>-1");
		List<JdataBean> list=query(condition);
		for(JdataBean bean:list){
			String str="";
			List<JdataBean> itemlist=getDao().queryFloorItem(bean.getString("id"));
			for(JdataBean item:itemlist)
				str+=item.getString("name")+" ";
			bean.put("itemsname", str);
		}
		return list;
	}
	public void delFloor(String id) throws Exception{
		getDao().delFloor(id);
	}
	
	public List<JdataBean> queryFloorItem(String floorid) throws Exception{
		return getDao().queryFloorItem(floorid);
	}
	public String saveFloorItem(JdataBean itembean,String[] products) throws HibernateException, Exception{
		String itemid=getDao().saveFloorItem(itembean);
		getDao().delFloorItemProducts(itemid);
		getDao().saveFloorItemProducts(itemid, products);
		return itemid;
	}
	public JdataBean getFloorItem(String id) throws Exception{
		return getDao().getFloorItem(id);
	}
	public void delFloorItem(String id) throws Exception{
		getDao().delFloorItem(id);
	}
	public PageResult queryFloorProduct(JdataBean parms,int size,int pageno) throws Exception{
		return getDao().queryFloorProduct(parms, size, pageno);
	}
	public void updatestatus(String floorid,int status) throws Exception{
		getDao().updatestatus(floorid, status);
	}
}
